Skip to content

Conversation

@dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Apr 24, 2025

Summary

This PR adds special-casing for @final and @override decorator for a similar reason as #17591 to support the invalid overload check.

Both final and override are identity functions which can be removed once TypeVar support is added.

@dhruvmanila dhruvmanila added the ty Multi-file analysis & type inference label Apr 24, 2025
@dhruvmanila dhruvmanila force-pushed the dhruv/final-staticmethod-override branch from 598c86b to 38e1a68 Compare April 24, 2025 16:53
@github-actions
Copy link
Contributor

github-actions bot commented Apr 24, 2025

mypy_primer results

No ecosystem changes detected ✅

@dhruvmanila dhruvmanila force-pushed the dhruv/final-staticmethod-override branch from 38e1a68 to 832935a Compare April 24, 2025 20:49
@dhruvmanila dhruvmanila changed the title [red-knot] Special case @final, @staticmethod, @override [red-knot] Special case @final, @override Apr 24, 2025
@dhruvmanila dhruvmanila marked this pull request as ready for review April 24, 2025 21:02
@dhruvmanila
Copy link
Member Author

I removed the @staticmethod special-casing because I realized that it would require additional change which could be as small as returning FunctionLiteral in the descriptor protocol. I made that as a quick change locally, will try it in a follow-up but I don't want to prioritize that much.

@dhruvmanila dhruvmanila force-pushed the dhruv/final-staticmethod-override branch from 832935a to 0cdf087 Compare April 24, 2025 21:10
@dhruvmanila dhruvmanila merged commit f1a539d into main Apr 24, 2025
34 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/final-staticmethod-override branch April 24, 2025 21:45
dcreager added a commit that referenced this pull request Apr 25, 2025
* main: (24 commits)
  [`airflow`] Extend `AIR301` rule (#17598)
  [`airflow`] update existing `AIR302` rules with better suggestions (#17542)
  red_knot_project: sort diagnostics from checking files
  [red-knot] fix detecting a metaclass on a not-explicitly-specialized generic base (#17621)
  [red-knot] fix inheritance-cycle detection for generic classes (#17620)
  [`pylint`] Detect `global` declarations in module scope (`PLE0118`) (#17411)
  Add Semantic Error Test for LateFutureImport (#17612)
  [red-knot] change TypeVarInstance to be interned, not tracked (#17616)
  [red-knot] Special case `@final`, `@override` (#17608)
  [red-knot] add TODO comment in specialization code (#17615)
  [`semantic-syntax-errors`] test for `LoadBeforeGlobalDeclaration` - ruff linter (#17592)
  [syntax-errors] `nonlocal` declaration at module level (#17559)
  [`airflow`] Apply auto fix to cases where name has been changed in Airflow 3 (`AIR311`) (#17571)
  [syntax-errors] Make `async-comprehension-in-sync-comprehension` more specific (#17460)
  Bump 0.11.7 (#17613)
  [red-knot] Use iterative approach to collect overloads (#17607)
  red_knot_python_semantic: avoid Rust's screaming snake case convention in mdtest
  red_knot_python_semantic: improve diagnostics for unsupported boolean conversions
  red_knot_python_semantic: add "return type span" helper method
  red_knot_python_semantic: move parameter span helper method
  ...
dcreager added a commit that referenced this pull request Apr 26, 2025
* main: (27 commits)
  [red-knot] Add new property tests for subtyping with "bottom" callable (#17635)
  [red-knot] Create generic context for generic classes lazily (#17617)
  ruff_db: add tests for annotations with no ranges
  [`airflow`] Extend `AIR301` rule (#17598)
  [`airflow`] update existing `AIR302` rules with better suggestions (#17542)
  red_knot_project: sort diagnostics from checking files
  [red-knot] fix detecting a metaclass on a not-explicitly-specialized generic base (#17621)
  [red-knot] fix inheritance-cycle detection for generic classes (#17620)
  [`pylint`] Detect `global` declarations in module scope (`PLE0118`) (#17411)
  Add Semantic Error Test for LateFutureImport (#17612)
  [red-knot] change TypeVarInstance to be interned, not tracked (#17616)
  [red-knot] Special case `@final`, `@override` (#17608)
  [red-knot] add TODO comment in specialization code (#17615)
  [`semantic-syntax-errors`] test for `LoadBeforeGlobalDeclaration` - ruff linter (#17592)
  [syntax-errors] `nonlocal` declaration at module level (#17559)
  [`airflow`] Apply auto fix to cases where name has been changed in Airflow 3 (`AIR311`) (#17571)
  [syntax-errors] Make `async-comprehension-in-sync-comprehension` more specific (#17460)
  Bump 0.11.7 (#17613)
  [red-knot] Use iterative approach to collect overloads (#17607)
  red_knot_python_semantic: avoid Rust's screaming snake case convention in mdtest
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants